package com.moment.hello.common.annotation;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.HashMap;

public class GetHelloFieldAnnotation {
    HashMap<Field, HelloAnnotation> methodAnnoMap = new HashMap<>();

    public GetHelloFieldAnnotation(Object object) {
        for (Field field : object.getClass().getFields()) {
            HelloAnnotation helloAnnotation = (HelloAnnotation) field.getAnnotation(HelloAnnotation.class);
            if (helloAnnotation != null) {
                methodAnnoMap.put(field, helloAnnotation);
            }
        }
    }

    public String getName(Field field) {
        return methodAnnoMap.containsKey(field) ? methodAnnoMap.get(field).name() : null;
    }

    public HelloAnnotation.Status getStatus(Field field) {
        return methodAnnoMap.containsKey(field) ? methodAnnoMap.get(field).status() : null;
    }
}
